<?php
//
namespace app\circle\controller\admin;

use app\circle\model\AdminModel;
use think\Controller;
use think\Request;

class PublicController extends Controller
{

    public function __construct(Request $request)
    {
        parent::__construct($request);
    }

    /*
     * 后台登录
     */
    public function login()
    {
        if ($this->request->isAjax()) {
            $adminName = $this->request->param('admin_name');
            $adminPass = $this->request->param('admin_pass');
            $adminModel = new AdminModel();
            $info = $adminModel->checkLogin($adminName,$adminPass);
            if($info===false){
                $this->error($adminModel->getError());
            }
            $loginToken = config('base.login_token');
            $circleDes = implode($loginToken,$info);
            cookie('circleDes',str_encode($circleDes));
            $this->success('登录成功！',url('admin.index/index'));
        }
        return $this->fetch();
    }

}
